var api = require('../../utils/api.js')

Page({
    data: {
        list: [],
        top:32,
        user:[]
    },
    onLoad() {
      var info = wx.getMenuButtonBoundingClientRect();
      console.log(info);
      
      var top = info.top;
      this.setData({
          top: top+32
      })
    },
    onShow() {
        let user = wx.getStorageSync('user');
        if (!user) {
            wx.navigateTo({
                url: '/pages/login/login'
            });
        }
        var that = this;
        api.get({
          url: 'wxapp/user/getUserInfo',
          data: {},
          success: data => {
            console.log(data);
            var user = data.data;
            that.setData({
              user: user
            })
          }
        });
   
    },

    getqrcode(){
        api.get({
            url: 'wxapp/Getqrcode/getqrcode',
            data: {},
            success: data => {
                console.log(data.data);
            }
        });

    },

    nexturl(ret){
      console.log(ret);
      var url=ret.currentTarget.dataset.url;

      wx.navigateTo({
        url: url
      })

    },

    scanCodeEvent(ret){


      wx.scanCode({
        onlyFromCamera: true,// 只允许从相机扫码
        success(res){
          console.log(res.result);

          var code=res.result;

          api.get({
            url: 'wxapp/user/ruku',
            data: {code:code},
            success: data => {
                console.log(data.data);

                wx.showToast({
                  title: data.msg,
                  icon:'none'
                })


            }
          });
   
          
     
        }
      })
  
    },

    getdesc(ret){
      console.log(ret);

      var value=ret.detail.value;

      api.get({
        url: 'wxapp/user/signature',
        data: {value:value},
        success: data => {
            console.log(data.data);
        }
      });



    }
});